package practice2;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class P8662 {

    static char[][] map;
    static boolean[][] isUsed;
    static int ans = 0;      //岛屿数量
    static int[] xArr={0,0,1,-1};       //走法
    static int[] yArr={1,-1,0,0};

    static class Points{
        int x;
        int y;
        public Points(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static boolean bfs(int x,int y){

        Queue<Points> queue =new LinkedList<>();
        Points points =new Points(x,y);
        queue.add(points);
        isUsed[x][y]=true;
        boolean falg = true;        //岛屿是否会完全淹没
        while(queue.size()>0){
            Points point = queue.remove();
            int count=0;
            for(int i=0;i<4;i++){
                int newX = point.x+xArr[i];
                int newY = point.y+yArr[i];
                if(map[newX][newY]=='#' && !isUsed[newX][newY]){
                    queue.add(new Points(newX,newY));
                    isUsed[newX][newY]=true;
                }
                if(map[newX][newY]=='#'){
                    count++;
                }
            }
            if(count==4){       //有四面全是陆地的陆地
                falg=false;
            }
        }
        return falg;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        map = new char[n+1][n+1];
        isUsed=new boolean[n+1][n+1];
        for(int i=1;i<=n;i++){
            String str = sc.next();
            for(int j=1;j<=n;j++){
                map[i][j]=str.charAt(j-1);
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(map[i][j] == '#' && !isUsed[i][j]){
                    //bfs,遍历改岛屿所有陆地并设为已走过，判断岛屿是否会完全淹没
                    if(bfs(i,j)){
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}
